<?php
declare(strict_types=1);

namespace App\Model;



use Hyperf\Database\Model\Events\Saving;
use Hyperf\Cache\Annotation\Cacheable;

/**
 * @property $id
 * @property $name
 * @property $mobile
 * @property $created_at
 * @property $updated_at
 */
class Menu extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    // protected $table = 'users';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    // protected $fillable = ['id', 'name', 'gender', 'created_at', 'updated_at'];
    protected array $hidden = ['created_at', 'updated_at'];
    protected array $appends = ['meta'];

    public function children() {
        return $this->hasMany(Menu::class, 'parent_id', 'id');
    }

    public function getMetaAttribute(){
        return $this->meta_info ? json_decode($this->meta_info, true) : [];
    }
}